import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
import { baseUrl } from '@/config'

export default new Vuex.Store({
	state: {
		token: '',
		user: null,
		clientId: '',
		wxUser: null,
		uploadUrl: `${baseUrl}sys/attachFiles/uploadAttachs`,
	},
	getters: {
		token: state => state.token,
		user: state => state.user,
		clientId: state => state.clientId,
		wxUser: state => state.wxUser,
	},
	mutations: {
		setToken(state, token) {
			state.token = token
			uni.setStorageSync('token', token)
		},
		setUser(state, user) {
			state.user = user
			uni.setStorageSync('user', user)
		},
		setClientId(state, clientId) {
			state.clientId = clientId
		},
		setWxUser(state, wxUser) {
			state.wxUser = wxUser
		}
	},
})